package com.tsm.picachu.level.ui;

import java.util.Timer;
import java.util.TimerTask;

import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;

import com.tsm.picachu.GeneralActivity;
import com.tsm.picachu.R;
import com.tsm.picachu.common.Constant;

public class UnlockLevelActivity extends GeneralActivity
{
	@Override
	protected void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);

		setContentView(R.layout.page_unlock_level);

		findViewById(R.id.unlock_level_continue).setOnClickListener(
				new OnClickListener()
				{
					public void onClick(View v)
					{
						startActivity(SelectLevelActivity.class);
					}
				});

		processImageAnim();
	}

	private void processImageAnim()
	{
		final View oppaView = findViewById(R.id.unlock_level_anim);

		TimerTask timerTask = new TimerTask()
		{
			private boolean isFirstBg = true;

			@Override
			public void run()
			{
				runOnUiThread(new Runnable()
				{
					public void run()
					{
						if (isFirstBg)
						{
							oppaView.setBackgroundResource(R.drawable.anim_unlock_level);
						}
						else
						{
							oppaView.setBackgroundResource(R.drawable.anim_unlock_level_1);
						}

						isFirstBg = !isFirstBg;
					}
				});
			}
		};

		Timer timer = new Timer();
		timer.schedule(timerTask, 0, Constant.TIME_ANIM_UNLOCK_LEVEL);
	}

}
